package cn.drew.basic.utils;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;


@AllArgsConstructor
@NoArgsConstructor
public class AjaxResult {

    private Boolean success;

    private String msg;

//    失败
    public static AjaxResult fail(){
        return AjaxResult.me().setSuccess(false).setMsg("操作失败");
    }
//    失败重载方法
    public static AjaxResult fail(String msg){
        return AjaxResult.me().setSuccess(false).setMsg("msg");
    }
//    成功
    public static AjaxResult success(){
        return AjaxResult.me().setSuccess(true).setMsg("操作成功");
    }




//    调用方法 返回一个新的对象
    private static AjaxResult me(){
        return new AjaxResult();
    }

    public Boolean getSuccess() {
        return success;
    }
    //修改无返回值为AjaxResult当前对象
    public AjaxResult setSuccess(Boolean success) {
        this.success = success;
        return this;
    }

    public String getMsg() {
        return msg;
    }
    //修改无返回值为AjaxResult当前对象
    public AjaxResult setMsg(String msg) {
        this.msg = msg;
        return this;
    }
}
